################################################################################
# GNU make should only be needed in maintainer mode now
################################################################################
# Please run 'configure' first (generate it with autogen.sh)
################################################################################

srcdir     = @srcdir@
top_srcdir = @top_srcdir@

PACKAGE = @PACKAGE@
VERSION = @VERSION@

PREFIX = @PREFIX@
BINDIR = @BINDIR@
LIBDIR = @LIBDIR@
CFGDIR = @CFGDIR@
LOCDIR = @LOCDIR@
KDEDIR = @KDEDIR@
DOCDIR = @DOCDIR@
MANDIR = @MANDIR@
GWMDIR = @GWMDIR@

EXEEXT = @EXEEXT@

INSTALL    = @INSTALL@
INSTALLDIR = @INSTALLDIR@
INSTALLBIN = @INSTALLBIN@
INSTALLLIB = @INSTALLLIB@
INSTALLETC = @INSTALLETC@
INSTALLMAN = @INSTALLMAN@
MKFONTDIR  = @MKFONTDIR@

DESTDIR     =

################################################################################

BINFILES    = @BINFILES@
LIBFILES    = lib/preferences lib/winoptions lib/keys \
              lib/menu lib/toolbar lib/taskbar2 # lib/programs
DOCFILES    = README BUGS CHANGES COPYING AUTHORS INSTALL VERSION icewm.lsm
MANFILES    = icewm.1
XPMDIRS     = icons ledclock taskbar mailbox cursors
THEMES      = nice motif win95 warp3 warp4 metal2 gtk2 Infadel2 nice2 \
              icedesert yellowmotif

GNOMEFILES  = lib/IceWM.desktop

all:		@TARGETS@
install:	@TARGETS_INSTALL@

base icesound icehelp:
	@cd src; $(MAKE) $@

docs:
	@cd doc; $(MAKE) all

nls:
	@cd po; $(MAKE) all

gnome:

srcclean:
	@cd src; $(MAKE) clean

clean:  srcclean
	@cd doc; $(MAKE) clean

distclean: clean
	rm -f *~ config.cache config.log config.status install.inc \
	sysdep.inc src/config.h \
	lib/preferences \
	lib/menu lib/programs lib/keys lib/winoptions lib/toolbar

maintainer-clean: distclean
	rm -f icewm.spec icewm.lsm Makefile configure src/config.h.in
	@cd doc; $(MAKE) maintainer-clean

check:
	@cd src ; $(MAKE) check >/dev/null

dist:	distclean docs configure

# Makefile TABS *SUCK*
install-base: base
	@echo ------------------------------------------
	@echo "Installing binaries in $(DESTDIR)$(BINDIR)"
	@$(INSTALLDIR) "$(DESTDIR)$(BINDIR)"
	@for bin in $(BINFILES); do \
             $(INSTALLBIN) "$${bin}" "$(DESTDIR)$(BINDIR)"; \
         done
	
	@echo "Installing presets and icons in $(DESTDIR)$(LIBDIR)"
	@$(INSTALLDIR) "$(DESTDIR)$(LIBDIR)"
	#-@$(INSTALLDIR) "$(DESTDIR)$(CFGDIR)"
	@for lib in $(LIBFILES); do \
             $(INSTALLLIB) "$${lib}" "$(DESTDIR)$(LIBDIR)"; \
         done

	@for xpmdir in $(XPMDIRS); do \
	     if test -d "lib/$${xpmdir}"; then \
		$(INSTALLDIR) "$(DESTDIR)$(LIBDIR)/$${xpmdir}"; \
		for pixmap in "lib/$${xpmdir}/"*.xpm; do \
		    $(INSTALLLIB) "$${pixmap}" "$(DESTDIR)$(LIBDIR)/$${xpmdir}"; \
		done; \
	    fi; \
        done
	
	@echo ------------------------------------------
	@for theme in $(THEMES); do \
	     SRCDIR="$(top_srcdir)" \
	     DESTDIR="$(DESTDIR)" \
	     LIBDIR="$(LIBDIR)" \
	     XPMDIRS="$(XPMDIRS)" \
	     INSTALLDIR="$(INSTALLDIR)" \
	     INSTALLLIB="$(INSTALLLIB)" \
	     MKFONTDIR="$(MKFONTDIR)" \
	     $(top_srcdir)/utils/install-theme.sh "$${theme}"; \
	done
	@#for a in $(ETCFILES) ; do $(INSTALLETC) "$$a" $(CFGDIR) ; done
	@echo ------------------------------------------

install-docs: docs
	@echo ------------------------------------------
	@rm -fr "$(DESTDIR)$(DOCDIR)/icewm-$(VERSION)"
	@$(INSTALLDIR) "$(DESTDIR)$(DOCDIR)/icewm-$(VERSION)"
	@echo "Installing documentation in $(DESTDIR)$(DOCDIR)"
	@$(INSTALLLIB) $(DOCFILES) "$(DESTDIR)$(DOCDIR)/icewm-$(VERSION)"
	@$(INSTALLLIB) "$(top_srcdir)/doc/"*.sgml "$(DESTDIR)$(DOCDIR)/icewm-$(VERSION)"
	@$(INSTALLLIB) "$(top_srcdir)/doc/"*.html "$(DESTDIR)$(DOCDIR)/icewm-$(VERSION)"
	@echo ------------------------------------------

install-nls: nls
	@echo ------------------------------------------
	@cd po; $(MAKE) install
	@echo ------------------------------------------

install-man:
	@$(INSTALLDIR) "$(DESTDIR)$(MANDIR)/man1"
	@for man in $(MANFILES); do \
		$(INSTALLMAN) doc/$$man.man $(DESTDIR)$(MANDIR)/man1/$$man; \
	done

install-gnome: gnome
	@echo ------------------------------------------
	@echo Installing icewm-gnome in $(DESTDIR)$(GWMDIR)
	@$(INSTALLDIR) "$(DESTDIR)$(GWMDIR)"
	@$(INSTALLLIB) "$(top_srcdir)/lib/IceWM.desktop" "$(DESTDIR)$(GWMDIR)"
	@echo ------------------------------------------
